#!/usr/bin/python3


from optparse import OptionParser
import sys
import os

sys.path.append("/usr/lib/linx-sec-center")
import ct_core

def create_parser():
    USAGE_MES="%prog \
            \n  Default: request no argument, you could input mac netlabel doi\
            \n          in stdin, and when you finished, Ctrl+D will be back \
            \n          and write the new doi to system if the The inputs correct!\
            \n Example:\
            \n secadmin~$ %prog \
            \n 12\
            \n EOF          "
    parse = OptionParser(usage=USAGE_MES,version="%prog 1.0")
    return parse

def set_doi_label():
    print("Please input the new doi:")
    l = sys.stdin.readline()
    ls = l.split()
    if len(ls) != 1:
        print("Sorry, you input doi %s is error!" %ls)
        return
    doi = ls[0]
    ct_core.write_mac_net_doi(doi)


def main():
    parser = create_parser()
    args,flg = parser.parse_args()

    if not flg:
        set_doi_label()
        return
    else:
        parser.error("Argument error, please specify a correct argument")

main()
